"""
# -*- coding: utf-8 -*-
# @Time    : 2023/5/21 22:29
# @Author  : 王摇摆
# @FileName: Plit.py
# @Software: PyCharm
# @Blog    ：https://blog.csdn.net/weixin_44943389?type=blog
在本程序中画出使用支持向量机线性分割后出来的结果图
"""

import numpy as np
import matplotlib.pyplot as plt
from SVM.SVM3.Test.Funciton import buildLine, X, y, a, b

Z = np.power(X, 2)

plt.rcParams['font.sans-serif'] = ['PingFang HK']  # 选择一个本地的支持中文的字体
fig, ax = plt.subplots()
ax.set_facecolor('#f8f9fa')

x1 = Z[y == -1][:, 0]
y1 = Z[y == -1][:, 1]
x2 = Z[y == 1][:, 0]
y2 = Z[y == 1][:, 1]
p1 = plt.scatter(x1, y1, c='#e63946', marker='o', s=20)
p2 = plt.scatter(x2, y2, c='#457b9d', marker='x', s=20)

x3, y3 = buildLine([1 / (a * a), 1 / (b * b)], -1, 0, 100)
p3, = plt.plot(x3, y3, '#38b000')

ax.set_xlabel('Z1', color='#264653')
ax.set_ylabel('Z2', color='#264653')
ax.tick_params(labelcolor='#264653')
plt.legend([p1, p2, p3], ["-EXP1", "EXP1", "Φ"], loc="upper right")
plt.show()
